<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text">
    
    <script>
        let input = document.querySelector('input')
// 键盘抬起
        input.onkeyup  = function(e){
            if (e.keyCode == '13') {
                console.log('你敲回车了');
                
            }
            
        }
        // 键盘按下
        onkeydown

    </script>
</body>
</html>